<?php
/**
 * 汽车之家车型大全类库API 离线版
 * @Copyright (C) 2019 比物福API All rights reserved.
 * @License http://tool.bitefu.com
 * @Author xiaogg <xiaogg@sina.cn>
 */
$getdata=$_REQUEST;if(empty($getdata))$getdata=$_POST?$_POST:$_GET;
$type=empty($getdata['type'])?'':$getdata['type'];
if(!in_array($type,array('brand','series','series_group','info','infoyear'))){
header("content-Type: text/html; charset=utf-8");
echo '<html><head><title>车型车系品牌api</title></head><body>参数 ?type=(brand,series,series_group,info,infoyear)&id=&keyword=<br />支持get 和 post 请求';return;}
error_reporting("E_ALL");ini_set("display_errors", 1);header("content-Type: application/json; charset=utf-8");
require_once('include/txtSQL.class.php');
require_once('include/txtSQL.core.php');
require_once('include/txtSQL.parser.php');
require_once("include/function.php");
require_once("include/Autohomeapi.class.php");
$postdata=array_map('htmlspecialchars',$getdata);
if(empty($postdata))$postdata=array_map('htmlspecialchars',$postdata);
if(!empty($postdata['page']))$postdata['page']=intval($postdata['page']);
if(empty($postdata['page']))$postdata['page']=1;
if(empty($postdata['pagesize']))$postdata['pagesize']=50;

$cachekey=md5(implode('',$postdata));
$result=filecache($cachekey);
if(empty($result)){
    $car = new Autohomeapi();
    switch($type){
        case 'brand':$result=$car->brand($postdata);break;
        case 'series':$result=$car->series($postdata);break;
        case 'series_group':$result=$car->series_group($postdata);break;
        case 'info':$result=$car->info($postdata);break;
        case 'infoyear':$result=$car->infoyear($postdata);break;
    }
    if($result)filecache($cachekey,$result);
}
ajaxReturn($result);
?>